import pygame
import sys
from init_map import InitMap


class Map(InitMap):
    def __init__(self, *args):
        InitMap.__init__(self)

        self.key_yellow = pygame.image.load("../资源/图片/黄钥匙.jpg").convert_alpha()
        self.key_blue = pygame.image.load("../资源/图片/蓝钥匙.jpg").convert_alpha()
        self.key_combine = pygame.image.load("../资源/图片/钥匙盒.png").convert_alpha()
        self.door_yellow = pygame.image.load("../资源/图片/黄门.jpg").convert_alpha()
        self.door_blue = pygame.image.load("../资源/图片/蓝门.png").convert_alpha()
        self.hp_red = pygame.image.load("../资源/图片/红药.jpg").convert_alpha()
        self.hp_blue = pygame.image.load("../资源/图片/蓝药.jpg").convert_alpha()
        self.gem_blue = pygame.image.load("../资源/图片/蓝宝石.jpg").convert_alpha()
        self.gem_red = pygame.image.load("../资源/图片/红宝石.jpg").convert_alpha()
        self.iron_shield = pygame.image.load("../资源/图片/铁盾.png").convert_alpha()
        self.little_bat = pygame.image.load("../资源/图片/小蝙蝠.jpg").convert_alpha()
        self.black_head = pygame.image.load("../资源/图片/青头怪.jpg").convert_alpha()
        self.kulou = pygame.image.load("../资源/图片/骷髅怪.jpg").convert_alpha()
        self.kulou_soldier = pygame.image.load("../资源/图片/骷髅士兵.jpg").convert_alpha()
        self.big_bat = pygame.image.load("../资源/图片/大蝙蝠.png").convert_alpha()
        self.primary_master = pygame.image.load("../资源/图片/初级法师.jpg").convert_alpha()
        self.animal_man = pygame.image.load("../资源/图片/兽面人.jpg").convert_alpha()
        self.primary_guard = pygame.image.load("../资源/图片/初级卫兵.png").convert_alpha()
        self.npc_man = pygame.image.load("../资源/图片/老头.png").convert_alpha()
        self.npc_woman = pygame.image.load("../资源/图片/老太.png").convert_alpha()

        self.hero_pos = (0, 9)
        self.up_pos = (9, 10)
        self.down_pos = (0, 10)
        self.variable_pos = {
            (1, 3): (self.door_yellow, '黄门'),
            (8, 2): (self.door_yellow, '黄门'),
            (5, 8): (self.door_yellow, '黄门'),
            (9, 8): (self.door_yellow, '黄门'),
            (8, 9): (self.door_yellow, '黄门'),
            (7, 8): (self.door_blue, '蓝门'),
            (7, 10): (self.key_yellow, '黄钥匙'),
            (9, 0): (self.key_yellow, '黄钥匙'),
            (10, 1): (self.key_yellow, '黄钥匙'),
            (10, 0): (self.key_blue, '蓝钥匙'),
            (0, 0): (self.key_combine, '钥匙盒'),
            (2, 0): (self.hp_red, '红药'),
            (4, 0): (self.hp_blue, '蓝药'),
            (7, 9): (self.gem_blue, '蓝宝石'),
            (0, 6): (self.gem_blue, '蓝宝石'),
            (0, 5): (self.gem_red, '红宝石'),
            (2, 1): (self.gem_red, '红宝石'),
            (4, 3): (self.iron_shield, '铁盾'),
            (2, 10): (self.little_bat, '小蝙蝠'),
            (3, 8): (self.little_bat, '小蝙蝠'),
            (5, 5): (self.little_bat, '小蝙蝠'),
            (5, 9): (self.little_bat, '小蝙蝠'),
            (6, 5): (self.kulou, '骷髅怪'),
            (4, 2): (self.kulou_soldier, '骷髅士兵'),
            (5, 3): (self.kulou_soldier, '骷髅士兵'),
            (9, 3): (self.kulou_soldier, '骷髅士兵'),
            (10, 4): (self.kulou_soldier, '骷髅士兵'),
            (3, 6): (self.black_head, '青头怪'),
            (3, 7): (self.black_head, '青头怪'),
            (0, 2): (self.big_bat, '大蝙蝠'),
            (0, 4): (self.big_bat, '大蝙蝠'),
            (2, 3): (self.primary_master, '初级法师'),
            (4, 1): (self.primary_master, '初级法师'),
            (5, 0): (self.primary_master, '初级法师'),
            (8, 0): (self.primary_master, '初级法师'),
            (9, 1): (self.primary_master, '初级法师'),
            (8, 3): (self.animal_man, '兽面人'),
            (8, 7): (self.animal_man, '兽面人'),
            (9, 7): (self.primary_guard, '初级卫兵'),
            (1, 7): (self.npc_man, '5楼老头'),
            (10, 3): (self.npc_woman, '5楼老太'),
        }

    def fixed_brick(self):
        self.draw(self.upstairs, self.up_pos[0], self.up_pos[1])
        self.dic[self.up_pos] = '上楼'
        self.draw(self.downstairs, self.down_pos[0], self.down_pos[1])
        self.dic[self.down_pos] = '下楼'
        for i in [(1, 0), (1, 1), (1, 2), (1, 4), (1, 5), (1, 6), (2, 6), (2, 7), (2, 8), (2, 9), (1, 8), (0, 8), (3, 0),
                  (3, 1), (3, 2), (3, 3), (3, 4), (4, 4), (5, 4), (6, 4), (6, 3), (6, 2), (7, 2), (9, 2), (10, 2), (4, 9),
                  (4, 8), (4, 7), (4, 6), (5, 6), (6, 6), (7, 6), (6, 8), (6, 9), (6, 10), (8, 8), (8, 10), (10, 8),
                  (10, 9), (10, 10)]:
            self.draw(self.wall, i[0], i[1])
            self.dic[(i[0], i[1])] = '墙'
        for i in self.ls:
            self.screen.blit(self.road, i)
            self.dic[(int((i[0]-375)/48), int((i[1]-25)/48))] = '路'
